<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      canvas {
        border: 1px solid #000;
        background: #f0f0f0;
      }
    </style>
  </head>
  <body>
    <canvas id="myCanvas" width="400" height="400"></canvas>
    <script>
      const canvas = document.getElementById("myCanvas")
      const ctx = canvas.getContext("2d")
      let angle = 0 // 初始角度
      const centerX = canvas.width / 2 // 圆心X坐标
      const centerY = canvas.height / 2 // 圆心Y坐标
      const radius = 150 // 圆弧半径
      const speed = 0.01 // 运动速度（弧度/帧）

      function drawCircle() {
        ctx.clearRect(0, 0, canvas.width, canvas.height)

        // 计算球坐标
        const x = centerX + radius * Math.cos(angle)
        const y = centerY + radius * Math.sin(angle)

        // 绘制球体
        ctx.beginPath()
        ctx.arc(x, y, 10, 0, Math.PI * 2)
        ctx.fillStyle = "#ff6b6b"
        ctx.fill()

        // 更新角度（顺时针运动）
        angle += speed

        // 保持角度在0-2π范围内
        angle = angle % (Math.PI * 2)

        requestAnimationFrame(drawCircle)
      }

      // 启动动画
      drawCircle()
    </script>
  </body>
</html>
